<template>
  <aplid-base-crud ref="crud" class="w-100" v-bind="baseConfig" :paramsObj="{isWithAuth:props.isWithAuth,idCard:nowRowData.idCard}"></aplid-base-crud>
</template>

<script setup lang="ts">
type Props = {
  isWithAuth?:any
  nowRowData?:any
}
let props = withDefaults(defineProps<Props>(),{
  isWithAuth:undefined,
  nowRowData:{}
})
import { getAreaObj } from '@/utils/util'
import { detailConfig } from '@/views/datacenter/business/healthArchives/config'

const baseConfig = {
  pageName: '健康档案',
  dictcodes: ['ACCESS_LEVEL_COUNTRY'],
  rowKey: 'id',
  api: {
    index: 'view_dpHealthBasicsArchives_page',
    detail: 'view_dpHealthBasicsArchives_view',
  },
  auth: {
    index: 'view_dpHealthBasicsArchives_page',
    detail: 'view_dpHealthBasicsArchives_view',
  },
  menuBtn: [
    {
      icon: 'detail',
      label: '查看详情',
      type: 'primary',
      operate: 'detail',
      auth: 'view_dpCommunityServiceOrder_page',
      text: true,
      show: true,
    },
  ],
  detailConfig,
  tableConfig: {
    stripe: true,
    border: false,
    tableLayout: 'auto',
    columns: [
      { label: '诊断人', prop: 'diagnoseName' },
      { label: '诊断单位', prop: 'diagnoseUnitName' },
      {
        label: '诊断时间',
        prop: 'diagnoseDate',
      },
      { label: '诊断结论', prop: 'diagnoseConclusion' },
      {
        label: '操作',
        prop: 'menu',
        width: 200,
        fixed: 'right',
      },
    ],
  },
  onLoadFormate: async (arr) => {
    const tableData = arr.map((item) => {
      const crAreas: any = getAreaObj(item, 'cr', 'get')
      const areas: any = getAreaObj(item, '', 'get')

      return {
        ...item,
        crAreas: crAreas.areaIds,
        cr_areas: crAreas.names,
        areas: areas.areaIds,
        areas_name: areas.names,
      }
    })
    return Promise.resolve(Object.freeze(tableData))
  },
}
</script>

<style scoped></style>
